package reflect;

import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;

public class ReflectDemo6 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException {
        Class cls=Class.forName("reflect.Person");
        Method method=cls.getMethod("say",String.class,int.class);

        String name=method.getName();
        System.out.println("方法名"+name);

        Class returnType=method.getReturnType();
        System.out.println("返回类型"+returnType);


        int modifiers=method.getModifiers();
        switch (modifiers){
            case Modifier.PUBLIC:
                System.out.println("public");
                break;
            case Modifier.PROTECTED:
                System.out.println("protected");
                break;
            case Modifier.PRIVATE:
                System.out.println("private");
                break;
            default:
                System.out.println("default");
        }
        Class[] types=method.getParameterTypes();
        System.out.println(Arrays.toString( types));

        int count=method.getParameterCount();
        System.out.println("参数的个数是："+ count);
    }
}
